#include "Ray.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(int argc, char ** argv)
{
	int i = 0;
	
	float * m = (float*) malloc(3*sizeof(float)); 
	float * p = (float*) malloc(3*sizeof(float)); 
	m[0] = -20.0; m[1] = -20.0; m[2] = -20.0;

	Camera_t 	camera;
	Screen_t 	screen;
	Ray_t 		ray;

	Create_Screen(&screen, 200, 200, 50.0, M_PI/4, M_PI/4);
	Camera_Init(&camera); 
	Move(&camera, m);

	fprintf(stdout, "\nlook(%f,%f,%f)up(%f,%f,%f)right(%f,%f,%f)\n\n",camera.look[0],camera.look[1],camera.look[2],camera.up[0],camera.up[1],camera.up[2],camera.right[0],camera.right[1],camera.right[2]);
	for(i=0; i<5; i++)
	{
		CreateRay(&ray, &camera, &screen, 100, 100);
		p[0] = ray.startPoint[0] + i*20.0 * ray.direction[0];
		p[1] = ray.startPoint[1] + i*20.0 * ray.direction[1];
		p[2] = ray.startPoint[2] + i*20.0 * ray.direction[2];
		fprintf(stdout,"Origen=(%f,%f,%f) dir=(%f,%f,%f) punto(%f,%f,%f)\n",ray.startPoint[0],ray.startPoint[1],ray.startPoint[2],ray.direction[0],ray.direction[1],ray.direction[2],p[0],p[1],p[2]);
	}

	RotateY(&camera,-45.0);
	fprintf(stdout, "\nlook(%f,%f,%f)up(%f,%f,%f)right(%f,%f,%f)\n\n",camera.look[0],camera.look[1],camera.look[2],camera.up[0],camera.up[1],camera.up[2],camera.right[0],camera.right[1],camera.right[2]);
	for(i=0; i<5; i++)
	{
		CreateRay(&ray, &camera, &screen, 100, 100);
		p[0] = ray.startPoint[0] + i*20.0 * ray.direction[0];
		p[1] = ray.startPoint[1] + i*20.0 * ray.direction[1];
		p[2] = ray.startPoint[2] + i*20.0 * ray.direction[2];
		fprintf(stdout,"Origen=(%f,%f,%f) dir=(%f,%f,%f) punto(%f,%f,%f)\n",ray.startPoint[0],ray.startPoint[1],ray.startPoint[2],ray.direction[0],ray.direction[1],ray.direction[2],p[0],p[1],p[2]);
	}
	

	Camera_Destroy(camera);
	destroyRay(ray);
	free(m);
	free(p);
	return 0;
}
